// async function async1() {
//     console.log('async1 start');
//     await async2();
//     console.log('async1 end');
// };

// async function async2() {
//     console.log('async2');
// };

// async1();
// console.log('start');


// async1 start -> async2 -> start -> async1 end

// 紧跟着await后面的语句相当于放到了new Promise中，下一行及之后的语句相当于放在Promise.then中

// 相当于把await转换为Promise.then的伪代码
async function async1() {
    console.log('async1 start');
    // 转换代码
    new Promise(resolve => {
        async2();
        resolve();
    }).then (res => console.log('async1 end'));
};

async function async2() {
    console.log('async2');
};

async1();
console.log('start');


// async1 start -> async2 -> start -> async1 end